package com.aspose.cells;

public class TextureFill extends Fill {
   private Object e;
   private Workbook f;
   private int g = 24;
   private Object h;
   String a = "";
   int b = 0;
   int c = -1;
   byte[] d;
   private int i = 100000;

   TextureFill(Object parent, Workbook workbook) {
      this.f = workbook;
      this.e = parent;
      this.h = new PicFormatOption();
   }

   void a(int var1) {
      this.c = var1;
      if (var1 != -1) {
         this.g = a(this.a());
      }

   }

   zcb a() {
      if (this.c == -1 && this.g != 24) {
         zcb var1 = new zcb();
         var1.a(zvj.a(this.g), this.f.getWorksheets().L());
         this.c = this.f.getWorksheets().Q().b().b(var1);
      }

      return this.c == -1 ? null : this.f.getWorksheets().Q().b().a(this.c);
   }

   static int a(zcb var0) {
      int var1 = 24;
      if (var0.f() != null) {
         var1 = a(var0.f().d);
      }

      if (var1 != 24) {
         return var1;
      } else {
         byte[] var2 = var0.h();
         return var2 != null ? MsoFillFormatHelper.b(var2) : var1;
      }
   }

   static int a(byte var0) {
      switch(var0) {
      case 0:
         return 13;
      case 1:
         return 3;
      case 2:
         return 5;
      case 3:
         return 23;
      case 4:
         return 21;
      case 5:
         return 12;
      case 6:
         return 6;
      case 7:
         return 18;
      case 8:
         return 8;
      case 9:
         return 22;
      case 10:
         return 2;
      case 11:
         return 7;
      case 12:
         return 10;
      case 13:
         return 17;
      case 14:
         return 14;
      case 15:
         return 19;
      case 16:
         return 0;
      case 17:
         return 15;
      case 18:
         return 16;
      case 19:
         return 1;
      case 20:
         return 4;
      case 21:
         return 20;
      case 22:
         return 11;
      case 23:
         return 9;
      default:
         return 24;
      }
   }

   byte[] b() {
      if (this.c == -1 && this.g != 24) {
         return zvj.a(this.g);
      } else {
         return this.c == -1 ? null : this.f.getWorksheets().Q().b().a(this.c).e();
      }
   }

   void a(byte[] var1) {
      zcb var2 = new zcb();
      var2.a(var1, this.f.getWorksheets().L());
      this.c = this.f.getWorksheets().Q().b().b(var2);
      this.g = a(var2);
   }

   public int getType() {
      return this.g;
   }

   public void setType(int value) {
      this.g = value;
      this.c = -1;
   }

   public byte[] getImageData() {
      if (this.d != null) {
         return this.d;
      } else {
         zcb var1 = null;
         if (this.c == -1) {
            if (this.g != 24) {
               var1 = new zcb();
               var1.a(zvj.a(this.g), this.f.getWorksheets().L());
               return var1.b();
            } else {
               return null;
            }
         } else {
            var1 = this.f.getWorksheets().Q().b().a(this.c);
            return var1.b();
         }
      }
   }

   public void setImageData(byte[] value) {
      this.c = this.f.getWorksheets().Q().a(value) - 1;
      zcb var2 = this.f.getWorksheets().Q().b().a(this.c);
      byte[] var3 = var2.h();
      if (var3 != null) {
         this.g = MsoFillFormatHelper.b(var3);
      } else {
         this.g = 24;
      }

   }

   public boolean isTiling() {
      return this.h instanceof TilePicOption;
   }

   public void setTiling(boolean value) {
      if (value) {
         if (this.h instanceof PicFormatOption) {
            this.h = new TilePicOption();
         }
      } else if (this.h instanceof TilePicOption) {
         this.h = new PicFormatOption();
      }

   }

   public PicFormatOption getPicFormatOption() {
      return this.isTiling() ? null : (PicFormatOption)this.h;
   }

   public void setPicFormatOption(PicFormatOption value) {
      this.h = value;
   }

   PicFormatOption c() {
      return this.isTiling() ? null : (PicFormatOption)this.h;
   }

   public TilePicOption getTilePicOption() {
      return this.isTiling() ? (TilePicOption)this.h : null;
   }

   public void setTilePicOption(TilePicOption value) {
      this.h = value;
   }

   public int getPictureFormatType() {
      return this.getPicFormatOption() == null ? 0 : this.getPicFormatOption().getType();
   }

   public void setPictureFormatType(int value) {
      if (this.getPicFormatOption() == null) {
         this.h = new PicFormatOption();
      }

      this.getPicFormatOption().setType(value);
   }

   public double getScale() {
      return this.getPicFormatOption() == null ? 100.0D : this.getPicFormatOption().getScale();
   }

   public void setScale(double value) {
      if (this.getPicFormatOption() == null) {
         this.h = new PicFormatOption();
      }

      this.getPicFormatOption().setScale(value);
   }

   int d() {
      return this.i;
   }

   void b(int var1) {
      this.i = var1;
   }

   int e() {
      return this.i / 1000;
   }

   void c(int var1) {
      this.i = var1 * 1000;
   }

   public double getTransparency() {
      return com.aspose.cells.b.a.zq.b((double)(100 - this.e()) / 100.0D, 2);
   }

   public void setTransparency(double value) {
      if (value >= 0.0D && value <= 1.0D) {
         int var3 = 100 - (int)(value * 100.0D);
         this.c(var3);
      } else {
         throw new CellsException(6, "Transparency must between 0.0 (opaque) and 1.0 (clear)");
      }
   }

   void a(TextureFill var1) {
      if (var1.c != -1) {
         if (var1.f == this.f) {
            this.c = var1.c;
            this.a().i();
         } else {
            this.setImageData(var1.getImageData());
         }
      }

      this.g = var1.g;
      this.i = var1.i;
      if (var1.h instanceof TilePicOption) {
         this.h = new TilePicOption();
         ((TilePicOption)this.h).a(var1.getTilePicOption());
      } else {
         this.h = new PicFormatOption();
         ((PicFormatOption)this.h).a(var1.getPicFormatOption());
      }

   }

   boolean b(TextureFill var1) {
      if (this.c != -1 && var1.c != -1 && this.getImageData() != var1.getImageData()) {
         return false;
      } else if (this.g != var1.g) {
         return false;
      } else if (this.i != var1.i) {
         return false;
      } else {
         if (var1.h != null || this.h != null) {
            if (var1.h == null || this.h == null) {
               return false;
            }

            if (var1.h instanceof TilePicOption) {
               if (!((TilePicOption)this.h).b(var1.getTilePicOption())) {
                  return false;
               }
            } else if (!((PicFormatOption)this.h).b(var1.getPicFormatOption())) {
               return false;
            }
         }

         return true;
      }
   }
}
